<HTML>
<!-- Mirrored from bos.asmhackers.net/docs/vga_without_bios/docs/0000.html by HTTrack Website Copier/3.x [XR&CO'2013], Tue, 07 Oct 2014 11:24:45 GMT -->
<HEAD><TITLE>port-arc: VGA driver changes for machines without built-in font</TITLE></HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000">
<B>Subject:</B> VGA driver changes for machines without built-in font<BR>
<B>To:</B> None <i>&lt;tech-kern&#64;netbsd.org&gt;</i><BR>
<B>From:</B> Izumi Tsutsui <i>&lt;tsutsui&#64;ceres.dti.ne.jp&gt;</i><BR>
<B>List:</B> port-arc<BR>
<B>Date:</B> 01/15/2003 22:42:05
<PRE>Hi,

I'm working for VGA console support of NEC Express5800/240 R4400 EISA
(NEC-J96A) on arc port and now it's almost done.
VGA console is working fine both text and rasterconsole on my J96A,
but I'd like any comments/suggestions before I commit them
because I'm not familiar with VGA and wscons.

Background:
NEC Express5800/240 (and maybe RISCserver2200) has the Cirrus Logic
GD5428 VGA chip on ISA for its console, but ARCBIOS on the machine
doesn't use text mode and vga_common_probe() in sys/dev/ic/vga_common.c
will fail if VGA is not set up in text mode, so it won't be attached
(even for rasterconsole).

Changes:
- Add an MI function vga_reset(), which initialize all VGA registers
  to set it up into text mode (mode 3: 640x400/31.5kHz/70Hz).
- Changes MD consinit() function to call vga_reset() with an
  initalization function for MD chipset.
- In vga.c (for text console), load 8x16 pixel wsfont in vga_init_screen()
  and skip vga_readoutchars() (which saves builtin font chars int memory)
  in vga_common_attach() if there isn't builtin font.
- In vga_raster.c (for raster console), use wsfont for console fontset
  rather than loading builtin font in vga_raster_init_screen().
- and some misc fixes/cosmetics.

Problems:
- Maybe vga_reset() should be in vga_common_probe() or vga_common_attach(),
  but current vga_common_probe() fails unless vga_reset() was called.
  In the current patch, MD consinit checks arc_displayc_id before
  calling vga_reset().
- I have no idea how to detect whether VGA has builtin font or not
  since vga_cnattach() function can't take any flags for it.
  In my current patch, MD consinit() set a global variable
  &quot;vga_no_bulitinfont&quot; and MI drivers check it, but I guess
  it's a bit ugly.
- Each VGA chipset would have &quot;extra&quot; registers and they should also
  be initialized (at least to support text mode), but there is
  no generic way to do it. For my NEC_J96A, MD consinit has
  a function gd54xx_initregs() (it's required to make textmode working),
  but I can't find any docs for the chipset so I'm using values taken
  from PC which uses the same Cirrus chip, but the most left bits on
  the screen are displayed wrong place (offset some lines).

Any comments would be appreciated.
---
Izumi Tsutsui
tsutsui&#64;ceres.dti.ne.jp

Index: dev/ic/vga.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/vga.c,v
retrieving revision 1.64
diff -u -r1.64 vga.c
--- dev/ic/vga.c	2002/10/15 17:30:43	1.64
+++ dev/ic/vga.c	2003/01/14 13:36:49
&#64;&#64; -54,13 +54,19 &#64;&#64;
 /* for WSCONS_SUPPORT_PCVTFONTS and WSDISPLAY_CHARFUNCS */
 #include &quot;opt_wsdisplay_compat.h&quot;
 
+int vga_no_builtinfont = 0;
+
 static struct wsdisplay_font _vga_builtinfont = {
-	&quot;builtin&quot;,
-	0, 256,
-	WSDISPLAY_FONTENC_IBM,
-	8, 16, 1,
-	WSDISPLAY_FONTORDER_L2R, 0,
-	0
+	&quot;builtin&quot;,			/* typeface name */
+	0,				/* firstchar */
+	256,				/* numbhars */
+	WSDISPLAY_FONTENC_IBM,		/* encoding */
+	8,				/* width */
+	16,				/* height */
+	1,				/* stride */
+	WSDISPLAY_FONTORDER_L2R,	/* bit order */
+	WSDISPLAY_FONTORDER_L2R,	/* byte order */
+	NULL				/* data */
 };
 
 struct egavga_font {
&#64;&#64; -469,6 +475,20 &#64;&#64;
 	scr-&gt;pcs.mem = NULL;
 
 	wsfont_init();
+	if (vga_no_builtinfont) {
+		struct wsdisplay_font *wf;
+		int cookie;
+
+		cookie = wsfont_find(NULL, 8, 16, 0,
+		     WSDISPLAY_FONTORDER_L2R, 0);
+		if (cookie == -1 || wsfont_lock(cookie, &amp;wf))
+			panic(&quot;can't load console font&quot;);
+		vga_loadchars(&amp;vc-&gt;hdl, 0, wf-&gt;firstchar, wf-&gt;numchars,
+		    wf-&gt;fontheight, wf-&gt;data);
+		vga_builtinfont.wsfont = wf;
+		vga_builtinfont.cookie = cookie;
+		vga_builtinfont.slot = 0;
+	}
 	scr-&gt;fontset1 = scr-&gt;fontset2 = 0;
 	if (vga_selectfont(vc, scr, 0, 0)) {
 		if (scr == &amp;vga_console_screen)
&#64;&#64; -584,12 +604,14 &#64;&#64;
 	KASSERT(vga_builtinfont.slot == 0);
 #define BUILTINFONTLOC (0)
 #endif
-	vga_builtinfont.wsfont-&gt;data =
-		malloc(256 * vga_builtinfont.wsfont-&gt;fontheight,
-		       M_DEVBUF, M_WAITOK);
-	vga_readoutchars(&amp;vc-&gt;hdl, BUILTINFONTLOC, 0, 256,
-			 vga_builtinfont.wsfont-&gt;fontheight,
-			 vga_builtinfont.wsfont-&gt;data);
+	if (!vga_no_builtinfont) {
+		vga_builtinfont.wsfont-&gt;data =
+		    malloc(256 * vga_builtinfont.wsfont-&gt;fontheight,
+		    M_DEVBUF, M_WAITOK);
+		vga_readoutchars(&amp;vc-&gt;hdl, BUILTINFONTLOC, 0, 256,
+				 vga_builtinfont.wsfont-&gt;fontheight,
+				 vga_builtinfont.wsfont-&gt;data);
+	}
 
 	vc-&gt;vc_type = type;
 	vc-&gt;vc_funcs = vf;
Index: dev/ic/vga_raster.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/vga_raster.c,v
retrieving revision 1.5
diff -u -r1.5 vga_raster.c
--- dev/ic/vga_raster.c	2002/11/28 07:02:20	1.5
+++ dev/ic/vga_raster.c	2003/01/14 13:36:51
&#64;&#64; -75,8 +75,10 &#64;&#64;
 
 #include &lt;dev/ic/pcdisplay.h&gt;
 
-u_int8_t builtinfont_data[256 * 16];
+int vga_no_builtinfont = 0;
 
+static u_int8_t builtinfont_data[256 * 16];
+
 struct wsdisplay_font builtinfont = {
 	&quot;builtin&quot;,			/* typeface name */
 	0,				/* firstchar */
&#64;&#64; -397,8 +399,6 &#64;&#64;
 	vc-&gt;nfonts = 1;
 	LIST_INIT(&amp;vc-&gt;vc_fontlist);
 	vf = &amp;vga_console_fontset_ascii;
-	vga_load_builtinfont(vh, builtinfont_data, 0, 256);
-	vf-&gt;font = &amp;builtinfont;
 	LIST_INSERT_HEAD(&amp;vc-&gt;vc_fontlist, vf, next);
 }
 
&#64;&#64; -415,10 +415,28 &#64;&#64;
 	scr-&gt;type = type;
 	scr-&gt;mindispoffset = 0;
 	scr-&gt;maxdispoffset = 0x10000;
-	scr-&gt;encoding = WSDISPLAY_FONTENC_IBM;
 	vh = &amp;vc-&gt;hdl;
 
 	wsfont_init();
+	if (vga_no_builtinfont) {
+		struct wsdisplay_font *wf;
+		int cookie;
+
+		/* prefer 8x16 pixel font */
+		cookie = wsfont_find(NULL, 8, 16, 0,
+		     WSDISPLAY_FONTORDER_L2R, 0);
+		if (cookie == -1)
+			cookie = wsfont_find(NULL, 0, 0, 0,
+			     WSDISPLAY_FONTORDER_L2R, WSDISPLAY_FONTORDER_L2R);
+		if (cookie == -1 || wsfont_lock(cookie, &amp;wf))
+			panic(&quot;can't load console font&quot;);
+		vga_console_fontset_ascii.font= wf;
+		scr-&gt;encoding = wf-&gt;encoding;
+	} else {
+		vga_load_builtinfont(vh, builtinfont_data, 0, 256);
+		vga_console_fontset_ascii.font = &amp;builtinfont;
+		scr-&gt;encoding = WSDISPLAY_FONTENC_IBM;
+	}
 	LIST_INIT(&amp;scr-&gt;fontset);
 	vga_raster_setup_font(vc, scr);
 
&#64;&#64; -449,7 +467,7 &#64;&#64;
 			    vh-&gt;vh_allmemh, 0x18000 + i * 2);
 			scr-&gt;mem[i].attr = bus_space_read_1(vh-&gt;vh_memt, 
 			    vh-&gt;vh_allmemh, 0x18000 + i * 2 + 1);			 
-			scr-&gt;mem[i].enc = WSDISPLAY_FONTENC_IBM;
+			scr-&gt;mem[i].enc = scr-&gt;encoding;
 		}
 
 		vga_raster_setscreentype(vc, type);
&#64;&#64; -790,7 +808,7 &#64;&#64;
 		}
 	}
 	
-	cookie = wsfont_find(0, 0, scr-&gt;type-&gt;fontheight, 0,
+	cookie = wsfont_find(NULL, 0, scr-&gt;type-&gt;fontheight, 0,
 	    WSDISPLAY_FONTORDER_L2R, 0);
 	if (cookie == -1)
 		return;
&#64;&#64; -833,9 +851,9 &#64;&#64;
 			mode-&gt;vdisplay *= 2;
 		if (mode-&gt;vdisplay &lt; 400)
 			regs-&gt;miscout = 0xa3;
-		if (mode-&gt;vdisplay &lt; 480)
+		else if (mode-&gt;vdisplay &lt; 480)
 			regs-&gt;miscout = 0x63;
-		if (mode-&gt;vdisplay &lt; 768)
+		else if (mode-&gt;vdisplay &lt; 768)
 			regs-&gt;miscout = 0xe3;
 		else
 			regs-&gt;miscout = 0x23;
&#64;&#64; -996,7 +1014,7 &#64;&#64;
 		scr-&gt;cursortmp.ch = 0;
 		scr-&gt;cursortmp.attr = 0;
 		scr-&gt;cursortmp.second = 0;
-		scr-&gt;cursortmp.enc = WSDISPLAY_FONTENC_IBM;
+		scr-&gt;cursortmp.enc = scr-&gt;encoding;
 	}
 	
 	scr-&gt;cursoron = 1;
&#64;&#64; -1110,7 +1128,7 &#64;&#64;
 	scr-&gt;mem[off].ch = c;
 	scr-&gt;mem[off].attr = attr;
 	scr-&gt;mem[off].second = 0;
-	scr-&gt;mem[off].enc = WSDISPLAY_FONTENC_IBM;
+	scr-&gt;mem[off].enc = scr-&gt;encoding;
 }
 
 static void
&#64;&#64; -1324,7 +1342,7 &#64;&#64;
 		scr-&gt;mem[off + i].ch = ' ';
 		scr-&gt;mem[off + i].attr = fillattr;
 		scr-&gt;mem[off + i].second = 0;
-		scr-&gt;mem[off + i].enc = WSDISPLAY_FONTENC_IBM;
+		scr-&gt;mem[off + i].enc = scr-&gt;encoding;
 	}
 }
 
Index: dev/ic/vga_subr.c
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/vga_subr.c,v
retrieving revision 1.11
diff -u -r1.11 vga_subr.c
--- dev/ic/vga_subr.c	2002/10/15 18:14:42	1.11
+++ dev/ic/vga_subr.c	2003/01/14 13:36:51
&#64;&#64; -42,6 +42,7 &#64;&#64;
 #include &lt;machine/bus.h&gt;
 
 #include &lt;dev/ic/mc6845reg.h&gt;
+#include &lt;dev/ic/pcdisplay.h&gt;
 #include &lt;dev/ic/pcdisplayvar.h&gt;
 #include &lt;dev/ic/vgareg.h&gt;
 #include &lt;dev/ic/vgavar.h&gt;
&#64;&#64; -50,6 +51,7 &#64;&#64;
 
 static void fontram(struct vga_handle *);
 static void textram(struct vga_handle *);
+static void vga_initregs(struct vga_handle *);

 static void
 fontram(struct vga_handle *vh)
&#64;&#64; -213,3 +215,186 &#64;&#64;
 	splx(s);
 }
 #endif /* !VGA_RASTERCONSOLE */
+
+/*
+ * vga_reset():
+ *	Reset VGA registers to put it into text mode.
+ *	This function should be called from MD consinit() on ports
+ *	whose firmware does not use text mode at boot time.
+ */
+void
+vga_reset(vh, md_initfunc)
+	struct vga_handle *vh;
+	void (*md_initfunc)(struct vga_handle *);
+{
+	u_int8_t reg;
+
+	if (bus_space_map(vh-&gt;vh_iot, 0x3c0, 0x10, 0, &amp;vh-&gt;vh_ioh_vga))
+		return;
+
+	reg = bus_space_read_1(vh-&gt;vh_iot, vh-&gt;vh_ioh_vga, VGA_MISC_DATAR);
+	vh-&gt;vh_mono = !(reg &amp; 0x01);
+
+	if (bus_space_map(vh-&gt;vh_iot, vh-&gt;vh_mono ? 0x3b0 : 0x3d0, 0x10,
+	    0, &amp;vh-&gt;vh_ioh_6845))
+		goto out1;
+
+	if (bus_space_map(vh-&gt;vh_memt, 0xa0000, 0x20000, 0, &amp;vh-&gt;vh_allmemh))
+		goto out2;
+
+	if (bus_space_subregion(vh-&gt;vh_memt, vh-&gt;vh_allmemh,
+	    vh-&gt;vh_mono ? 0x10000 : 0x18000, 0x8000, &amp;vh-&gt;vh_memh))
+		goto out3;
+
+	/* check if VGA already in text mode. */
+	if ((vga_gdc_read(vh, misc) &amp; 0x01) == 0)
+		goto out3;
+
+	/* initialize common VGA registers */
+	vga_initregs(vh);
+
+	/* initialize chipset specific registers */
+	if (md_initfunc != NULL)
+		(*md_initfunc)(vh);
+
+	delay(10000);
+
+	/* clear text buffer RAM */
+	bus_space_set_region_2(vh-&gt;vh_memt, vh-&gt;vh_memh, 0,
+	    ((BG_BLACK | FG_LIGHTGREY) &lt;&lt; 8) | ' ', 80 * 25 /*XXX*/);
+
+ out3:
+	bus_space_unmap(vh-&gt;vh_memt, vh-&gt;vh_allmemh, 0x20000);
+ out2:
+	bus_space_unmap(vh-&gt;vh_iot, vh-&gt;vh_ioh_6845, 0x10);
+ out1:
+	bus_space_unmap(vh-&gt;vh_iot, vh-&gt;vh_ioh_vga, 0x10);
+}
+
+/*
+ * values to initialize registers.
+ */
+
+/* sequencer registers */
+static const u_int8_t vga_ts[] = {
+	0x03,	/* 00: reset */
+	0x01,	/* 01: clocking mode */
+	0x03,	/* 02: map mask */
+	0x00,	/* 03: character map select */
+	0x02	/* 04: memory mode */
+};
+
+/* CRT controller registers */
+static const u_int8_t vga_crtc[] = {
+	0x5f,	/* 00: horizontal total */
+	0x4f,	/* 01: horizontal display-enable end */
+	0x50,	/* 02: start horizontal blanking */
+	0x82,	/* 03: display skew control / end horizontal blanking */
+	0x55,	/* 04: start horizontal retrace pulse */
+	0x81,	/* 05: horizontal retrace delay / end horizontal retrace */
+	0xbf,	/* 06: vetical total */
+	0x1f,	/* 07: overflow register */
+	0x00,	/* 08: preset row scan */
+	0x4f,	/* 09: overflow / maximum scan line */
+	0x0d,	/* 0A: cursor off / cursor start */
+	0x0e,	/* 0B: cursor skew / cursor end */
+	0x00,	/* 0C: start regenerative buffer address high */
+	0x00,	/* 0D: start regenerative buffer address low */
+	0x00,	/* 0E: cursor location high */
+	0x00,	/* 0F: cursor location low */
+	0x9c,	/* 10: vertical retrace start */
+	0x8e,	/* 11: vertical interrupt / vertical retrace end */
+	0x8f,	/* 12: vertical display enable end */
+	0x28,	/* 13: logical line width */
+	0x00,	/* 14: underline location */
+	0x96,	/* 15: start vertical blanking */
+	0xb9,	/* 16: end vertical blanking */
+	0xa3,	/* 17: CRT mode control */
+	0xff	/* 18: line compare */
+};
+
+/* graphics controller registers */
+static const u_int8_t vga_gdc[] = {
+	0x00,	/* 00: set/reset map */
+	0x00,	/* 01: enable set/reset */
+	0x00,	/* 02: color compare */
+	0x00,	/* 03: data rotate */
+	0x00,	/* 04: read map select */
+	0x10,	/* 05: graphics mode */
+	0x0e,	/* 06: miscellaneous */
+	0x00,	/* 07: color don't care */
+	0xff	/* 08: bit mask */
+};
+
+/* attribute controller registers */
+static const u_int8_t vga_atc[] = {
+	0x00,	/* 00: internal pallet  0 */
+	0x01,	/* 01: internal pallet  1 */
+	0x02,	/* 02: internal pallet  2 */
+	0x03,	/* 03: internal pallet  3 */
+	0x04,	/* 04: internal pallet  4 */
+	0x05,	/* 05: internal pallet  5 */
+	0x14,	/* 06: internal pallet  6 */
+	0x07,	/* 07: internal pallet  7 */
+	0x38,	/* 08: internal pallet  8 */
+	0x39,	/* 09: internal pallet  9 */
+	0x3a,	/* 0A: internal pallet 10 */
+	0x3b,	/* 0B: internal pallet 11 */
+	0x3c,	/* 0C: internal pallet 12 */
+	0x3d,	/* 0D: internal pallet 13 */
+	0x3e,	/* 0E: internal pallet 14 */
+	0x3f,	/* 0F: internal pallet 15 */
+	0x08,	/* 10: attribute mode control */
+	0x00,	/* 11: overscan color */
+	0x0f,	/* 12: color plane enable */
+	0x08,	/* 13: horizontal PEL panning */
+	0x00	/* 14: color select */
+};
+
+static void
+vga_initregs(vh)
+	struct vga_handle *vh;
+{
+	int i;
+
+	/* disable video */
+	vga_ts_write(vh, mode, vga_ts[1] | 0x20);
+
+	if (vga_no_builtinfont) {
+		/* clear font ram to avoid displaying garbage */
+		fontram(vh);
+		bus_space_set_region_1(vh-&gt;vh_memt, vh-&gt;vh_allmemh,
+		    0, 0x00, 32 * 16 * 256);
+	}
+
+	/* synchronous reset */
+	vga_ts_write(vh, syncreset, 0x01);
+	/* set TS regs */
+	for (i = 2; i &lt; VGA_TS_NREGS; i++)
+		_vga_ts_write(vh, i, vga_ts[i]);
+	/* clear synchronous reset */
+	vga_ts_write(vh, syncreset, 0x03);
+
+	/* unprotect CRTC regs */
+	_vga_crtc_write(vh, 17, vga_crtc[17] &amp; ~0x80);
+	/* set CRTC regs */
+	for (i = 0; i &lt; VGA_CRTC_NREGS; i++)
+		_vga_crtc_write(vh, i, vga_crtc[i]);
+
+	/* set GDC regs */
+	for (i = 0; i &lt; VGA_GDC_NREGS; i++)
+		_vga_gdc_write(vh, i, vga_gdc[i]);
+
+	/* set DAC PEL mask */
+	bus_space_write_1(vh-&gt;vh_iot, vh-&gt;vh_ioh_vga, 6, 0xff);
+
+	/* set ATC regs */
+	for (i = 0; i &lt; VGA_ATC_NREGS; i++)
+		_vga_attr_write(vh, i, vga_atc[i]);
+
+	/* set misc output register */
+	bus_space_write_1(vh-&gt;vh_iot, vh-&gt;vh_ioh_vga, VGA_MISC_DATAW, 0x63);
+
+	/* reenable video */
+	vga_ts_write(vh, mode, vga_ts[1] &amp; ~0x20);
+}
Index: dev/ic/vgavar.h
===================================================================
RCS file: /cvsroot/src/sys/dev/ic/vgavar.h,v
retrieving revision 1.15
diff -u -r1.15 vgavar.h
--- dev/ic/vgavar.h	2002/10/15 18:14:42	1.15
+++ dev/ic/vgavar.h	2003/01/14 13:36:51
&#64;&#64; -210,3 +210,6 &#64;&#64;
 #else /* !VGA_RASTERCONSOLE */
 void 	vga_load_builtinfont(struct vga_handle *, u_int8_t *, int, int);
 #endif /* !VGA_RASTERCONSOLE */
+void	vga_reset(struct vga_handle *, void (*)(struct vga_handle *));
+
+extern int vga_no_builtinfont;
\ No newline at end of file
Index: arch/arc/arc/c_jazz_eisa.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arc/arc/c_jazz_eisa.c,v
retrieving revision 1.2
diff -u -r1.2 c_jazz_eisa.c
--- arch/arc/arc/c_jazz_eisa.c	2002/12/09 13:36:26	1.2
+++ arch/arc/arc/c_jazz_eisa.c	2003/01/14 13:36:51
&#64;&#64; -52,6 +52,11 &#64;&#64;
 #include &lt;arc/jazz/pccons_jazziovar.h&gt;
 #endif
 
+#include &quot;vga_isa.h&quot;
+#if NVGA_ISA &gt; 0
+#include &lt;dev/isa/vga_isavar.h&gt;
+#endif
+
 #include &quot;vga_jazzio.h&quot;
 #if NVGA_JAZZIO &gt; 0
 #include &lt;arc/jazz/vga_jazziovar.h&gt;
&#64;&#64; -155,6 +160,17 &#64;&#64;
 			return;
 		}
 #endif
+
+#if NVGA_ISA &gt; 0
+		if (vga_isa_cnattach(&amp;arc_bus_io, &amp;arc_bus_mem) == 0) {
+#if NPCKBC_JAZZIO &gt; 0
+			pckbc_cnattach(&amp;jazzio_bus, PICA_SYS_KBD,
+			    JAZZIO_KBCMDP, PCKBC_KBD_SLOT);
+#endif
+			return;
+		}
+#endif
+
 #if NPC_JAZZIO &gt; 0
 		if (pccons_jazzio_cnattach(arc_displayc_id, &amp;jazzio_bus) == 0)
 			return;
Index: arch/arc/arc/c_nec_eisa.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arc/arc/c_nec_eisa.c,v
retrieving revision 1.4
diff -u -r1.4 c_nec_eisa.c
--- arch/arc/arc/c_nec_eisa.c	2002/12/09 13:38:30	1.4
+++ arch/arc/arc/c_nec_eisa.c	2003/01/14 13:36:52
&#64;&#64; -32,6 +32,7 &#64;&#64;
 
 #include &lt;sys/param.h&gt;
 #include &lt;sys/systm.h&gt;
+#include &lt;sys/kcore.h&gt;
 #include &lt;sys/device.h&gt;
 #include &lt;uvm/uvm_extern.h&gt;
 
&#64;&#64; -42,12 +43,23 &#64;&#64;
 
 #include &lt;dev/isa/isavar.h&gt;
 
+#include &lt;arc/arc/arcbios.h&gt;
 #include &lt;arc/arc/wired_map.h&gt;
 #include &lt;arc/jazz/pica.h&gt;
 #include &lt;arc/jazz/rd94.h&gt;
 #include &lt;arc/jazz/jazziovar.h&gt;
 #include &lt;arc/isa/isabrvar.h&gt;
 
+#include &quot;vga_isa.h&quot;
+#if NVGA_ISA &gt; 0
+#include &lt;dev/ic/mc6845reg.h&gt;
+#include &lt;dev/ic/pcdisplayvar.h&gt;
+#include &lt;dev/ic/vgareg.h&gt;
+#include &lt;dev/ic/vgavar.h&gt;
+
+static void gd54xx_initregs(struct vga_handle *);
+#endif
+
 /*
  * chipset-dependent isa bus configuration
  */
&#64;&#64; -146,3 +158,82 &#64;&#64;
 	/* chipset-dependent jazzio bus configuration */
 	jazzio_conf = &amp;jazzio_nec_eisa_conf;
 }
+
+void
+c_nec_eisa_cons_init()
+{
+
+#if NVGA_ISA &gt; 0
+	if (strcmp(arc_displayc_id, &quot;necvdfrb&quot;) == 0) {
+		/* NEC RISCserver 2200 R4400 EISA [NEC-R96] */
+		/* NEC Express5800/240 R4400 EISA [NEC-J96A] */
+		struct vga_handle handle;
+
+		vga_no_builtinfont = 1;
+		handle.vh_memt = &amp;arc_bus_mem;
+		handle.vh_iot = &amp;arc_bus_io;
+		vga_reset(&amp;handle, gd54xx_initregs);
+	}
+#endif
+
+	c_jazz_eisa_cons_init();
+}
+
+#if NVGA_ISA &gt; 0
+
+/* values to initialize cirrus GD54xx specific ext registers */
+/* XXX these values are taken from PC XXX */
+static const u_int8_t vga_ts_gd54xx[] = {
+	0x0f,	/* 05: ??? */
+	0x12,	/* 06: enable ext reg (?) */
+	0x00,	/* 07: reset ext sequence (?) */
+	0x00,	/* 08: ??? */
+	0x5c,	/* 09: ??? */
+	0x09,	/* 0A: ??? */
+	0x4a,	/* 0B: ??? */
+	0x5b,	/* 0C: ??? */
+	0x42,	/* 0D: VCLK2 frequency */
+	0x00,	/* 0E: ??? */
+	0x09,	/* 0F: ??? */
+	0x00,	/* 10: ??? */
+	0x00,	/* 11: ??? */
+	0x00,	/* 12: ??? */
+	0x00,	/* 13: ??? */
+	0x00,	/* 14: ??? */
+	0x00,	/* 15: ??? */
+	0xd8,	/* 16: ??? */
+	0x39,	/* 17: ??? */
+	0x00,	/* 18: ??? */
+	0x01,	/* 19: ??? */
+	0x00,	/* 1A: ??? */
+	0x2b,	/* 1B: ??? */
+	0x2f,	/* 1C: ??? */
+	0x1f,	/* 1D: VCLK2 denominator and post-scalar value */
+	0x00,	/* 1E: ??? */
+	0x19	/* 1F: ??? */
+	/* XXX needs more ?? */
+};
+
+static void
+gd54xx_initregs(vh)
+	struct vga_handle *vh;
+{
+	int i;
+
+	/* disable video */
+	vga_ts_write(vh, mode, vga_ts_read(vh, mode) | 0x20);
+
+	/* enable access to GD54xx ext regs */
+	_vga_ts_write(vh, 0x06, 0x12);
+
+	/* setup GD54xx ext regs */
+	for (i = 0; i &lt; sizeof(vga_ts_gd54xx); i++)
+		_vga_ts_write(vh, 0x05 + i, vga_ts_gd54xx[i]);
+	
+	/* disable access to GD54xx ext regs */
+	_vga_ts_write(vh, 0x06, 0x0);
+
+	/* reenable video */
+	vga_ts_write(vh, mode, vga_ts_read(vh, mode) &amp; ~0x20);
+}
+#endif
Index: arch/arc/arc/p_nec_j96a.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arc/arc/p_nec_j96a.c,v
retrieving revision 1.3
diff -u -r1.3 p_nec_j96a.c
--- arch/arc/arc/p_nec_j96a.c	2002/12/09 13:36:27	1.3
+++ arch/arc/arc/p_nec_j96a.c	2003/01/14 13:36:52
&#64;&#64; -43,7 +43,7 &#64;&#64;
 	c_jazz_eisa_mainbusdevs,
 	platform_generic_match,
 	c_nec_eisa_init,
-	c_jazz_eisa_cons_init,
+	c_nec_eisa_cons_init,
 	jazzio_reset,
 	c_nec_jazz_set_intr,
 };
Index: arch/arc/arc/p_nec_r96.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arc/arc/p_nec_r96.c,v
retrieving revision 1.1
diff -u -r1.1 p_nec_r96.c
--- arch/arc/arc/p_nec_r96.c	2001/06/13 15:35:04	1.1
+++ arch/arc/arc/p_nec_r96.c	2003/01/14 13:36:52
&#64;&#64; -49,7 +49,7 &#64;&#64;
 	c_jazz_eisa_mainbusdevs,
 	platform_generic_match,
 	c_nec_eisa_init,
-	c_jazz_eisa_cons_init,
+	c_nec_eisa_cons_init,
 	jazzio_reset,
 	c_nec_jazz_set_intr,
 };
Index: arch/arc/conf/GENERIC
===================================================================
RCS file: /cvsroot/src/sys/arch/arc/conf/GENERIC,v
retrieving revision 1.79
diff -u -r1.79 GENERIC
--- arch/arc/conf/GENERIC	2003/01/04 21:09:31	1.79
+++ arch/arc/conf/GENERIC	2003/01/14 13:36:52
&#64;&#64; -226,8 +226,10 &#64;&#64;
 
 pc0		at isa? irq 1			# generic PC console device
 opms0		at isa? irq 12			# PS/2 auxiliary port mouse
-#vga0		at isa?
-#pckbc0		at isa?				# PC keyboard controller
+vga0		at isa?
+#options 	VGA_RASTERCONSOLE
+options 	FONT_VT220L8x16
+pckbc0		at isa?				# PC keyboard controller
 com0		at isa? port 0x3f8 irq 4
 com1		at isa? port 0x2f8 irq 3
 com2		at isa? port 0x3e8 irq 4
Index: arch/arc/include/platform.h
===================================================================
RCS file: /cvsroot/src/sys/arch/arc/include/platform.h,v
retrieving revision 1.2
diff -u -r1.2 platform.h
--- arch/arc/include/platform.h	2002/11/30 19:23:47	1.2
+++ arch/arc/include/platform.h	2003/01/14 13:36:53
&#64;&#64; -92,6 +92,7 &#64;&#64;
 void c_magnum_init __P((void));
 
 void c_nec_eisa_init __P((void));
+void c_nec_eisa_cons_init __P((void));
 
 void c_nec_jazz_set_intr __P((int, int (*) __P((u_int, struct clockframe *)),
     int));
</PRE>
</BODY>
<!-- Mirrored from bos.asmhackers.net/docs/vga_without_bios/docs/0000.html by HTTrack Website Copier/3.x [XR&CO'2013], Tue, 07 Oct 2014 11:24:45 GMT -->
</HTML>
